package pers.tgb.blog.support;

/**
 * HTTP返回CODE枚举类
 * 
 *
 */
public enum HttpCode {
	/** 200请求成功 **/
	OK(200),
	/** 400请求参数出错 **/
	BAD_REQUEST(400),
	/** 404找不到页面 **/
	NOT_FOUND(404),
	/** 409业务异常 */
	CONFLICT(409),
	/** 500服务器出错 **/
	INTERNAL_SERVER_ERROR(500);

	private final Integer value;

	private HttpCode(Integer value) {
		this.value = value;
	}

	/**
	 * 
	 * Return the integer value of this status code.
	 * 
	 */
	public Integer value() {
		return this.value;
	}

	public String msg() {
		switch(this.value) {
			case 200:
				return "OK";
			case 400:
				return "BAD_REQUEST";
			case 404:
				return "NOT_FOUND";
			case 500:
				return "INTERNAL_SERVER_ERROR";
			default:
				return "OK";
		}		
	}

	public String toString() {
		return this.value.toString();
	}
}
